<template>
  <div align="center">
    <h1>学生</h1>
    <p>您的学生</p>
    <table>
      <tr>

        <td>姓名</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in stu">
        <td>{{ i.name }}</td>
        <td>
          <button @click="putstu(i.id)">删除</button>
        </td>
      </tr>
    </table>

  </div>
</template>

<script>
export default {
  name: "getstu",
  data() {
    return {
      tea: localStorage.getItem('userid'),
      stu: []
    }

  },
  methods: {
    get_stu() {
      this.$axios.get('stu/?tea=' + this.tea)
        .then(res => {
          this.stu = res.data.list
        })
    },
    putstu(id) {
      this.$axios.put('stu/?id=' + id)
        .then(res => {
          if (res.data.code == 200) {
            alert('删除成功')
            this.get_stu()
          }
        })
    }
  },
  mounted() {
    this.get_stu()
  }
}
</script>

<style scoped>

</style>
